package com.venue.hjt.venueclass.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.venue.hjt.venueclass.R;
import com.venue.hjt.venueclass.bean.VenueBookingBean;
import com.venue.hjt.venueclass.db.VenueBooKing;

import java.util.List;

/**

 */

public class VenueComplaintAdapter extends BaseAdapter {
    private Context mContext;
    private List<VenueBookingBean.Data> list;
    public VenueComplaintAdapter(Context mContext, List<VenueBookingBean.Data> list) {
        this.mContext = mContext;
        this.list = list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHander viewHander;
        if (convertView==null){
            viewHander=new ViewHander();
            convertView= View.inflate(mContext, R.layout.complaint_item,null);
            viewHander.tv_complaint_name=convertView.findViewById(R.id.tv_complaint_name);
            viewHander.tv_complaint_time=convertView.findViewById(R.id.tv_complaint_time);
            viewHander.iv_y=convertView.findViewById(R.id.iv_y);
            convertView.setTag(viewHander);
        }else{
            viewHander= (ViewHander) convertView.getTag();
        }

        VenueBookingBean.Data data = list.get(position);
        if (data.is_complaint){
            viewHander.iv_y.setImageResource(R.drawable.venue_complaint_y1);
        }else {
            viewHander.iv_y.setImageResource(R.drawable.venue_complaint_y);
        }
        viewHander.tv_complaint_name.setText(data.groupname);
        viewHander.tv_complaint_time.setText(data.start_time+"～"+data.end_time+" "+data.date);
        return convertView;
    }
    class ViewHander{
        TextView tv_complaint_name,tv_complaint_time;
        ImageView iv_y;
    }


}
